Skip to content

Conversation

@ma-r-s
Copy link
Collaborator

@ma-r-s ma-r-s commented Oct 2, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a visually appealing image carousel for displaying offers.
    • Added a tabbed row for category navigation with icons.
    • Created a structured home screen layout with various UI components including a search bar and stores grid.
  • Bug Fixes

    • Updated import paths for the HomeScreen component to reflect package restructuring.
  • Chores

    • Updated library and plugin versions for improved performance and compatibility.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several changes to the Android application, primarily focusing on the build.gradle.kts file, where dependencies and configuration settings are updated. Notably, the androidx.appcompat dependency is removed. Multiple new Kotlin files are added, including HomeScreen.kt, Carousel.kt, CategoriesRow.kt, StoresGrid.kt, TopSection.kt, each defining composable functions that enhance the UI. Additionally, import paths for the HomeScreen component are updated across various files to reflect a new package structure.

Changes

File Path Change Summary
app/build.gradle.kts Updated application configuration, removed androidx.appcompat, modified dependencies, and set version references.
app/src/main/java/com/uniandes/ecobites/MainActivity.kt Updated import path for HomeScreen.
app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt Updated import path for HomeScreen.
app/src/main/java/com/uniandes/ecobites/ui/screens/home/Carousel.kt Added new composable function OfferCarousel.
app/src/main/java/com/uniandes/ecobites/ui/screens/home/CategoriesRow.kt Added new composable function CategoriesRow and data class Category.
app/src/main/java/com/uniandes/ecobites/ui/screens/home/HomeScreen.kt Added new composable function HomeScreen.
app/src/main/java/com/uniandes/ecobites/ui/screens/home/StoresGrid.kt Added new composable function StoresGrid, data class Store, and StoreItem function.
app/src/main/java/com/uniandes/ecobites/ui/screens/home/TopSection.kt Added new composable function TopSection.
gradle/libs.versions.toml Updated library versions, added new version references for Compose and runtime libraries.

Possibly related PRs

  • Views cart login register #15: The changes in app/build.gradle.kts regarding the removal of the androidx.appcompat dependency are directly related to the addition of the same dependency in the retrieved PR, indicating a shift in how the app manages its dependencies.

🐰 In a world of screens so bright,
A carousel spins with delight.
Categories row, a tabbed parade,
New homes and stores in colors displayed.
With every change, our app takes flight,
Hopping forward, oh what a sight! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ma-r-s ma-r-s linked an issue Oct 2, 2024 that may be closed by this pull request
@ma-r-s ma-r-s self-assigned this Oct 2, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (10)
app/src/main/java/com/uniandes/ecobites/ui/screens/home/HomeScreen.kt (2)

15-17: Add KDoc comment for HomeScreen function

The function declaration looks good. The use of @OptIn(ExperimentalMaterial3Api::class) is noted, which is appropriate for using experimental Material 3 components.

Consider adding a KDoc comment to describe the purpose of the HomeScreen function. For example:

/**
 * Composable function that represents the main home screen of the EcoBites app.
 * It displays various sections including a top bar, offer carousel, categories, and stores grid.
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen() {
    // ... (existing code)
}

18-41: Remove unnecessary comment and consider performance optimization

The overall structure of the HomeScreen function looks good. It's well-organized with clear sections and consistent spacing.

Remove the unnecessary commented line:

-//         Offer Carousel Section

Consider using LazyColumn instead of Column with verticalScroll for better performance, especially if the content might grow large. LazyColumn would allow for more efficient rendering of only the visible items. Here's a suggested refactor:

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items

@Composable
fun HomeScreen() {
    LazyColumn(
        modifier = Modifier
            .fillMaxSize()
            .padding(16.dp)
    ) {
        item { TopSection() }
        item { Spacer(modifier = Modifier.height(16.dp)) }
        item { OfferCarousel() }
        item { Spacer(modifier = Modifier.height(16.dp)) }
        item { CategoriesRow() }
        item { Spacer(modifier = Modifier.height(16.dp)) }
        item { StoresGrid() }
    }
}

This change would be particularly beneficial if StoresGrid contains a large number of items or if more sections are added to the home screen in the future.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/Carousel.kt (1)

30-37: Review carousel configuration.

The carousel configuration looks good overall, but there are a few points to consider:

  1. The commented-out contentPadding might be useful. Consider if you want to add padding around the carousel items.
  2. There's a slight inconsistency between the carousel height (250.dp) and the image height (300.dp). This might cause unexpected visual results.

Consider adjusting the heights to be consistent:

- modifier = Modifier.height(250.dp).fillMaxWidth(),
+ modifier = Modifier.height(300.dp).fillMaxWidth(),

Also, decide whether to use the contentPadding:

- //        contentPadding = PaddingValues(horizontal = 40.dp)
+ contentPadding = PaddingValues(horizontal = 16.dp)
gradle/libs.versions.toml (1)

Line range hint 1-33: Overall, good updates towards modern Android development.

These changes to gradle/libs.versions.toml indicate a significant update to the project's dependencies, particularly in relation to Jetpack Compose. This is a positive step towards more modern Android development practices.

Key points:

  1. Version updates for multiple libraries, including new Compose-related entries.
  2. Consistent updates in the libraries section to use these new versions.

Recommendations:

  1. Document the rationale behind these updates, especially in relation to issue #12.
  2. Verify compatibility with the rest of the project and make any necessary code adjustments.
  3. Consider creating a migration guide if these changes require significant updates in other parts of the codebase.

As you're moving towards more Compose-based development, consider reviewing your overall application architecture. Compose works well with MVVM or MVI patterns, so you might want to ensure your architecture aligns well with Compose best practices.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/CategoriesRow.kt (2)

15-23: LGTM: Well-structured Category data class and list.

The Category data class and the categories list are well-defined and appropriate for the use case. The category names and associated icons are relevant to a food-related application and follow Material Design guidelines.

For future extensibility, consider moving the categories list to a separate file or making it configurable, allowing for easy addition or modification of categories without changing the UI code.


25-62: LGTM: Well-implemented CategoriesRow composable.

The CategoriesRow composable function is well-structured and follows Jetpack Compose best practices. It correctly implements a scrollable tab row with icons and text, handles state management, and provides appropriate styling and spacing.

Note the use of ExperimentalMaterial3Api. Keep track of Material 3 API changes in future updates to ensure stability.

Consider improving accessibility by adding a contentDescription to the Tab composable, not just the Icon. This will help screen readers better understand the purpose of each tab. For example:

Tab(
    selected = selectedTabIndex == index,
    onClick = { selectedTabIndex = index },
    text = { ... },
    modifier = Modifier.semantics {
        contentDescription = "Select ${category.name} category"
    }
)
app/src/main/java/com/uniandes/ecobites/ui/screens/home/StoresGrid.kt (1)

18-24: Consider aligning store selection with the app's eco-friendly theme.

The current list of stores includes a mix of supermarkets and fast food chains. Given the app name "EcoBites", it might be more appropriate to focus on eco-friendly or sustainable food options.

Consider replacing some or all of the current stores with more environmentally-conscious alternatives, such as local organic markets, zero-waste stores, or restaurants known for their sustainable practices.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/TopSection.kt (3)

21-26: LGTM: Function declaration and state management look good.

The TopSection composable function is correctly annotated and the state declarations use the appropriate Compose state management techniques.

Consider adding a comment explaining the purpose of the isActive state variable for better code readability:

// Tracks whether the search bar is currently active (expanded)
var isActive by remember { mutableStateOf(false) }

28-42: UI structure looks good, but consider parameterizing the address.

The Column and Row layouts are well-structured with appropriate modifiers. The use of Icon and Text components for the location display is correct.

However, the address "Calle 13 #10-22" is hardcoded. Consider parameterizing this value to make the component more reusable:

-@Composable
-fun TopSection() {
+@Composable
+fun TopSection(address: String) {
     // ... existing code ...
-    Text(text = "Calle 13 #10-22", style = MaterialTheme.typography.bodyMedium)
+    Text(text = address, style = MaterialTheme.typography.bodyMedium)
     // ... existing code ...
}

// Update the Preview to include a sample address
@Preview(showBackground = true)
@Composable
fun TopSectionPreview() {
    TopSection(address = "Calle 13 #10-22")
}

46-69: SearchBar implementation looks great, with a minor suggestion.

The SearchBar is well-implemented using Material 3 components and follows Compose best practices. The use of modifiers for size constraints and the implementation of placeholder text, icons, and state management are all correct.

The empty content block at the end of the SearchBar (lines 67-69) can be removed if it's not being used:

 SearchBar(
     // ... existing properties ...
-) {
-    // You can provide additional content here if needed
-}
+)

If you plan to add content later, consider adding a TODO comment instead of leaving it empty.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee3a977 and 4ffcdc3.

⛔ Files ignored due to path filters (9)
  • app/src/main/res/drawable/dunkin_donuts.png is excluded by !**/*.png
  • app/src/main/res/drawable/exito.jpeg is excluded by !**/*.jpeg
  • app/src/main/res/drawable/fiftyoff.png is excluded by !**/*.png
  • app/src/main/res/drawable/free_delivery.png is excluded by !**/*.png
  • app/src/main/res/drawable/hornitos.jpeg is excluded by !**/*.jpeg
  • app/src/main/res/drawable/mc_donalds.png is excluded by !**/*.png
  • app/src/main/res/drawable/pan_pa_ya.png is excluded by !**/*.png
  • app/src/main/res/drawable/percent.png is excluded by !**/*.png
  • app/src/main/res/drawable/two_for_one.png is excluded by !**/*.png
📒 Files selected for processing (10)
  • app/build.gradle.kts (0 hunks)
  • app/src/main/java/com/uniandes/ecobites/MainActivity.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/HomeScreen.kt (0 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/home/Carousel.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/home/CategoriesRow.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/home/HomeScreen.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/home/StoresGrid.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/home/TopSection.kt (1 hunks)
  • gradle/libs.versions.toml (2 hunks)
💤 Files with no reviewable changes (2)
  • app/build.gradle.kts
  • app/src/main/java/com/uniandes/ecobites/ui/screens/HomeScreen.kt
✅ Files skipped from review due to trivial changes (2)
  • app/src/main/java/com/uniandes/ecobites/MainActivity.kt
  • app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt
🔇 Additional comments (12)
app/src/main/java/com/uniandes/ecobites/ui/screens/home/HomeScreen.kt (1)

1-42: Overall, well-structured and modular HomeScreen implementation

The HomeScreen.kt file introduces a well-organized and modular structure for the main home screen of the EcoBites app. The use of custom composables for different sections promotes reusability and maintainability.

Key points for improvement:

  1. Add the missing import for TopSection.
  2. Include a KDoc comment for the HomeScreen function to improve documentation.
  3. Consider using LazyColumn for potential performance benefits, especially if the content might grow larger in the future.

These changes will enhance the code quality, documentation, and potentially the performance of the home screen.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/Carousel.kt (3)

16-18: Function signature looks good.

The OfferCarousel function is properly annotated with @Composable and @ExperimentalMaterial3Api. The name is descriptive and follows the convention for Composable functions.


1-47: Overall implementation is good with room for refinement.

The OfferCarousel composable function successfully implements a horizontal carousel using Jetpack Compose and Material 3. The code is well-structured and follows Compose conventions. However, there are opportunities for improvement in terms of flexibility, consistency, and best practices. Consider the suggested refinements to enhance maintainability, accessibility, and error handling.


1-15: Consider the implications of using experimental APIs.

The code imports and uses ExperimentalMaterial3Api, which indicates the use of experimental features. While this is not inherently problematic, it's important to be aware that experimental APIs may change in future releases, potentially causing breaking changes in your app.

To ensure you're using the most up-to-date version of Material 3, please run the following command:

This will help verify if you're using the latest stable version or if there's a more recent version available that might have stabilized these APIs.

gradle/libs.versions.toml (2)

Line range hint 15-29: Library updates are consistent, but consider broader impact.

The updates to the library entries, particularly for androidx-material3 and the addition of androidx-runtime-android, are consistent with the version changes and suggest an expanded use of Compose features. This is a positive direction for modern Android development.

However, to ensure a smooth transition:

  1. Please verify if any other libraries in your project need to be updated for consistency with these Compose-related changes.
  2. Check if any code changes are needed to accommodate these library updates, especially if new Compose features are being introduced.

To help identify any other libraries that might need updating or any potential code changes required, you can run:

This will help you identify areas of your code that might be affected by these library updates.

✅ Verification successful

Library Updates Verified Successfully

The updates to the Compose-related libraries are consistent and properly integrated across the codebase. No issues were found based on the recent checks.

  • Compose imports, Material3 usages, and runtime-android usages are present and correctly referenced in the project files.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for Compose-related imports and usages in the project

# Test: Search for Compose imports
echo "Compose imports:"
rg --type kotlin 'import androidx.compose'

# Test: Search for Material3 usages
echo "\nMaterial3 usages:"
rg --type kotlin 'Material3'

# Test: Search for runtime-android usages
echo "\nruntime-android usages:"
rg --type kotlin 'androidx.compose.runtime'

Length of output: 19652


Line range hint 1-12: Version updates look good, but please provide more context.

The version updates and new entries for Compose-related libraries are appropriate. However, to ensure project stability and maintainability:

  1. Please verify that these updated versions are compatible with the rest of your project dependencies.
  2. Consider documenting the reason for these updates, especially how they relate to issue #12 mentioned in the PR title. This will help with future maintenance and understanding of the project's evolution.

To help verify the compatibility of these versions with your project, you can run the following command:

This will output a dependency tree, allowing you to spot any conflicts or incompatibilities.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/CategoriesRow.kt (2)

1-13: LGTM: Imports are appropriate and concise.

The imports cover all necessary Jetpack Compose components and Material icons required for the implementation. There are no unused or redundant imports.


1-62: Great addition: CategoriesRow component aligns well with PR objectives.

This new file introduces a well-implemented CategoriesRow component that enhances the UI by providing a structured way to display categories with icons in a tabbed format. The code is clean, follows Jetpack Compose best practices, and aligns perfectly with the PR objectives (Closes #12).

The suggestions provided are minor and aimed at future improvements:

  1. Consider making the categories list more configurable for easier maintenance.
  2. Improve accessibility by adding content descriptions to tabs.
  3. Keep an eye on the experimental Material 3 API in future updates.

Overall, this is a solid contribution that adds value to the project.

app/src/main/java/com/uniandes/ecobites/ui/screens/home/StoresGrid.kt (3)

1-12: LGTM: Imports are well-organized and relevant.

The imports cover all necessary Jetpack Compose libraries and resources required for the implementation. There are no unused imports, and they are logically organized.


15-15: LGTM: Store data class is well-defined.

The Store data class is simple and appropriate for representing store information in this context.


1-77: Overall, great implementation of the StoresGrid using Jetpack Compose!

The code is well-structured and follows Jetpack Compose best practices. The suggestions provided aim to enhance flexibility, responsiveness, and alignment with the app's theme. Great job on implementing this feature!

app/src/main/java/com/uniandes/ecobites/ui/screens/home/TopSection.kt (1)

1-18: LGTM: Package declaration and imports are appropriate.

The package declaration follows the standard Android naming convention, and all imports are relevant to Jetpack Compose UI development. There are no unused imports, which is good for code cleanliness.

Copy link
Contributor

@LuimarcoCarrascalDiaz LuimarcoCarrascalDiaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am Luimarco, and I approve this message

@ma-r-s ma-r-s merged commit cbec9e7 into main Oct 2, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 3, 2024
This was referenced Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature/vista home

3 participants